package com.mioto.ld.module.device.dao;

import com.mioto.ld.module.device.model.*;
import com.mioto.ld.module.statistics.model.AppAlertStatisticVO;
import com.mioto.ld.module.statistics.model.AppStatisticSearchDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 *
 * @author mioto
 * @date 2024-05-15 16:13:50
 */
@Mapper
public interface DeviceAlertLogDao{

    /**
     * 根据条件查询列表
     * @param deviceAlertLog
     * @return
     */
    List<DeviceAlertLog> findList(DeviceAlertLog deviceAlertLog);

    /**
     * 根据列名和对应的值查询对象
     * @param column
     * @param value
     * @return
     */
    DeviceAlertLog findByColumn(@Param("column") String column,@Param("value") Object value);

    /**
     * 新增对象
     * @param deviceAlertLog
     * @return
     */
    int insert(DeviceAlertLog deviceAlertLog);

    /**
     * 新增对象,忽略空值
     * @param deviceAlertLog
     * @return
     */
    int insertIgnoreNull(DeviceAlertLog deviceAlertLog);

    /**
     * 修改对象
     * @param deviceAlertLog
     * @return
     */
    int update(DeviceAlertLog deviceAlertLog);

    /**
     * 修改对象,忽略空值
     * @param deviceAlertLog
     * @return
     */
    int updateIgnoreNull(DeviceAlertLog deviceAlertLog);

    /**
     * 根据列名和对应的值删除对象
     * @param column
     * @param value
     * @return
     */
    int deleteByColumn(@Param("column") String column,@Param("value") Object value);

    /**
     * 根据主键列表批量删除
     * @param ids
     * @return
     */
    int batchDelete(Integer[] ids);

    List<DeviceAlertLogPagerVO> findPager(@Param("deviceId")Integer deviceId, @Param("startTime")String startTime,
                                          @Param("endTime")String endTime,@Param("userId")Integer userId);

    DeviceAlertLog findLastLevelAlert(@Param("alertId")int alertId, @Param("deviceId")int deviceId);

    int updateRecoveryData(@Param("deviceId")Integer deviceId,@Param("alertIds") Set<Integer> alertIds
            ,@Param("recoveryDate") Date reportTime,@Param("recoveryCondition") String jsonStr);

    List<DeviceAlertLogAppPagerVO> findAppPager(@Param("userId")Integer userId, @Param("alertType")String alertType,@Param("deviceIds")Integer[] deviceIds);

    List<DeviceAlertCounterStatisticsVO> counterStatistics(@Param("start")Date start, @Param("end")Date now,
                                                     @Param("type")int type, @Param("userId")Integer userId);
    List<DeviceAlertLevelStatisticsVO> levelStatistics(@Param("start")Date start, @Param("end")Date now,
                                                       @Param("userId")Integer userId);

    List<DeviceAlertCounterStatisticsVO> appCounterStatistics(AppStatisticSearchDTO searchDTO);

    AppAlertStatisticVO mainCounterStatistic(AppStatisticSearchDTO searchDTO);
}